export const pointsPopup = [{
    id: '001',
    name: '弹窗1',
    position: [117.228268, 31.912469, 33.3],
    url: "http://data.mars3d.cn/file/video/lukou.mp4"
  },
  {
    id: '002',
    name: '弹窗2',
    position: [117.258714, 31.891885, 33.3],
    url: "https://sf1-hscdn-tos.pstatp.com/obj/media-fe/xgplayer_doc_video/flv/xgplayer-demo-360p.flv"
  },
  {
    id: '003',
    name: '弹窗3',
    position: [117.21807, 31.838378, 33.3],
    url: "http://1252093142.vod2.myqcloud.com/4704461fvodcq1252093142/f865d8a05285890787810776469/playlist.f3.m3u8"
  }
];

export const pointsProjection = [{
    id: '101',
    name: '投影1',
    position: [117.228268, 31.912469, 0],
    angle: 27,
    angle2: 12,
    heading: 230,
    pitch: 0,
    roll: 0,
    distance: 78,
    showFrustum: true,
    url: "http://data.mars3d.cn/file/video/lukou.mp4",
  },
  {
    id: '102',
    name: '投影2',
    position: [117.21807, 31.838378, 0],
    angle: 46.3,
    angle2: 15.5,
    heading: 178.5,
    pitch: 8.2,
    roll: 0,
    distance: 78,
    showFrustum: true,
    url: "https://sf1-hscdn-tos.pstatp.com/obj/media-fe/xgplayer_doc_video/flv/xgplayer-demo-360p.flv",
  },
  {
    id: '103',
    name: '投影3',
    position: [117.258714, 31.891885, 0],
    angle: 50.3,
    angle2: 20.5,
    heading: 178.5,
    pitch: 8.2,
    roll: 0,
    distance: 78,
    showFrustum: true,
    url: "http://1252093142.vod2.myqcloud.com/4704461fvodcq1252093142/f865d8a05285890787810776469/playlist.f3.m3u8",
  }
];



let pointsProjection3d = [{
  id: '101',
  name: '土建楼',
  position: '114.30430, 30.48682, 16.0000',
  angle: 30,
  angle2: 17,
  heading: 224.5,
  pitch: 6.4,
  roll: 3,
  distance: 70,
  showFrustum: false,
  opacity: 1,
  url: "/static/video/tujianlou.mp4",
  play: false
  // url: "http://1252093142.vod2.myqcloud.com/4704461fvodcq1252093142/f865d8a05285890787810776469/playlist.f3.m3u8"
},{
  id: '102',
  name: '土建楼街道',
  position: '114.304187,30.486755,15.8',
  angle: 30,
  angle2: 17,
  heading: 85.08041,
  pitch: 2.98601,
  roll: 2.80296,
  distance: 300,
  showFrustum: false,
  opacity: 1,
  url: "/static/video/jiedao.mp4",
  play: false
  // url: "http://1252093142.vod2.myqcloud.com/4704461fvodcq1252093142/f865d8a05285890787810776469/playlist.f3.m3u8"
}];


// 获取监控列表
export function getProjectionList () {
  return new Promise((resolve, reject) => {
    const data = JSON.parse(JSON.stringify(pointsProjection3d))
    resolve(data)
  })
}

// 添加监控
export function addProjection (data) {
  const d = {id: getUUId(), ...data}
  pointsProjection3d.push(d)
  return Promise.resolve(d)
}

// 编辑监控
export function editProjection (data) {
  pointsProjection3d = pointsProjection3d.map(item => item.id === data.id ? data : item)
  return Promise.resolve()
}

// 删除监控
export function delProjection (data) {
  const index = pointsProjection3d.findIndex(item => item.id === data.id)
  pointsProjection3d.splice(index, 1)
  return Promise.resolve()
}

function getUUId() {
  let tem = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
  let id = "",
    len = tem.length,
    i = 0;
  for (i; i < len; i++) {
    if (tem[i] == "-") id += tem[i];
    else {
      let num = Math.floor(Math.random() * 16);
      id += num.toString(16);
    }
  }
  return id;
}